package net.thermetics.fx.auth;

import java.util.Collection;
import java.util.Set;


import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;

public class GaeUserAuthentication implements Authentication {
	private static final long serialVersionUID = 1L;
	
	private GaeUser principal;
	private Object details;
	private boolean authenticated;
	
	public GaeUserAuthentication(GaeUser principal, Object details) {
		this.principal = principal;
		this.details = details;
	}
	@Override
	public String getName() {
		return null;
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public Collection<GrantedAuthority> getAuthorities() {
		Set junk = principal.getAuthorities();
		return junk;
	}

	@Override
	public Object getCredentials() {
		return principal;
	}

	@Override
	public Object getDetails() {
		return details;
	}

	@Override
	public Object getPrincipal() {
		return principal;
	}

	@Override
	public boolean isAuthenticated() {
		return authenticated;
	}

	@Override
	public void setAuthenticated(boolean authenticated) throws IllegalArgumentException {
		this.authenticated = authenticated;
	}

}
